unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms,Controls, Graphics, Dialogs, StdCtrls,
  Spin,Unit2;

type
 { TForm1 }
   TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    CheckBox1: TCheckBox;
    Edit1: TEdit;
    Edit2: TEdit;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    SpinEdit1: TSpinEdit;
    SpinEdit2: TSpinEdit;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
 Form1: TForm1;
 name:string;
 programname:string;
 procedurenum:longint;
 functionnum:longint;
 filenot:boolean;
 i,j:integer;

implementation

{ TForm1 }


procedure TForm1.Button1Click(Sender: TObject);

begin
  name:=Edit1.Text;
  programname:=Edit2.Text;
  functionnum:=SpinEdit1.Value;
  procedurenum:=SpinEdit2.Value;
  filenot:=CheckBox1.Checked;
  {buildtitle}
  assignfile(output,programname+'.pas');
  rewrite(output);
  writeln('{');
  writeln(output,'ID:',name);
  writeln(output,'PROG:',programname);
  writeln('LANG: PASCAL');
  writeln('}');
  {buildmain}
  writeln(output,'program',' ',programname,';');
  writeln(output,'const');
  writeln;
  writeln(output,'var');
  writeln;
  if procedurenum=0 then begin end
                    else begin
  for i:= 1 to procedurenum do
   begin
     writeln(output,'procedure',' ',i,';' );
     writeln(output,' ','begin');
     writeln(output,' ','end;');
     writeln;
   end;{for}
  end;
  if functionnum=0 then begin end
                    else begin
  for j:= 1 to functionnum do
   begin
    writeln(output,'function',' ',j,';' );
    writeln(output,' ','begin');
    writeln(output,' ','end;');
    writeln;
   end;{for}
  end;
    writeln(output,'begin');
   {build I/O Files}
   if filenot=True then begin
   writeln(output,'    assign(input,',chr(39),programname,'.in',chr(39),');');
   writeln(output,'    reset(input);');
   writeln(output,'    assign(output,',chr(39),programname,'.out',chr(39),');');
   writeln(output,'    rewrite(output);');
   writeln(output,'    close(input);');
   writeln(output,'    close(output);');
   writeln(output,'end.');
   closefile(output);
   assignfile(output,programname+'.in');
   rewrite(output);
   writeln(output);
   closefile(output);
   end {if}
              else  begin
                     writeln('end.');
                     closefile(output);
                    end;
 end;{procedure}

procedure TForm1.Button2Click(Sender: TObject);
begin
 Form1.Close;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
 Form2.ShowModal;
end;

initialization
  {$I Unit1.lrs}

end.


